CC        := gcc
ROOT      := $(shell pwd)
INCS      := $(ROOT)/include
OUTPUT    := $(ROOT)/build
BIN       := $(ROOT)/bin
TARGET    := main
SRC_PATH  := lib1 lib2 srcmake 
CFLAGS    := $(foreach dir, $(INCS), -I$(dir))

export CC CFLAGS OUTPUT

.PHONY : $(TARGET) clean $(SRC_PATH)

$(TARGET) : $(SRC_PATH)
	@echo 可重定位文件编译完成，开始链接...
	@mkdir -p $(BIN)
	@gcc $(wildcard $(OUTPUT)/*.o) -o $(BIN)/$@
	@echo 编译完成!

lib1: ;$(MAKE) -C $(ROOT)/$@
lib2: ;$(MAKE) -C $(ROOT)/$@
src:  ;$(MAKE) -C $(ROOT)/$@

clean:
	@echo 清理工作开始...
	@rm -rf $(OUTPUT)
	@rm -rf $(BIN)
	@echo 清理结束!!!
